﻿#region  文件信息

// ---------------------------------------------------------------------------------------
// <copyright file="AliPayService.cs" company="">
// 作者：李帅伦
// </copyright>
// <summary>
// 类型简介：
// 类型详细：AliPayService.cs
// 创建时间：2014-12-25 16:54
// 修改时间：2014-12-25 15:03
// </summary>
// ---------------------------------------------------------------------------------------
#endregion

namespace Payment.Albaba.PcCode
{
    #region

    using System.Collections.Generic;
    using System.Threading;

    using Payment.Albaba.Com;

    #endregion

    /// <summary>
    ///     业务参数
    /// </summary>
    public class AliPayService : Dictionary<string, string>
    {
        #region Constructors and Destructors

        /// <summary>
        /// 支付宝配置
        /// </summary>
        public AliConfig Config { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="AliPayService"/> class.
        ///     业务参数集合.
        /// </summary>
        /// <param name="payOrder">
        /// 支付订单接口
        /// </param>
        /// <param name="seller">
        /// The seller.
        /// </param>
        public AliPayService(IPayOrder payOrder, AliSeller seller)
            : this(payOrder)
        {
            this.SellerEmail = seller.SellerEmail;
            this.OutTradeNo = payOrder.GetId();
            this.SellerId = seller.SellerId;
            this.TotalFee = payOrder.GetTotalFee();
            this.Subject = payOrder.GetSubject();
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="AliPayService"/> class. 
        /// 业务参数集合.
        /// </summary>
        /// <param name="payOrder">
        /// </param>
        public AliPayService(IPayOrder payOrder)
        {
            this.PaymentType = "1";
            this.OutTradeNo = payOrder.GetId();
            this.TotalFee = payOrder.GetTotalFee();
            this.Subject = payOrder.GetSubject();
        }
        #endregion

        #region Public Properties

        /// <summary>
        ///     支付宝合作商户网站唯一订单号。
        /// </summary>
        public string OutTradeNo
        {
            get
            {
                return this["out_trade_no"];
            }

            protected set
            {
                this["out_trade_no"] = value;
            }
        }

        /// <summary>
        ///     支付类型 取值范围请参见附录“11.6  收款类型”。
        /// </summary>
        public string PaymentType
        {
            get
            {
                return this["payment_type"];
            }

            protected set
            {
                this["payment_type"] = value;
            }
        }

        /// <summary>
        ///   卖家id
        /// </summary>
        public string SellerId
        {
            get
            {
                return this["seller_id"];
            }

            protected set
            {
                this["seller_id"] = value;
            }
        }

        /// <summary>
        ///   卖家账号
        /// </summary>
        public string SellerEmail
        {
            get
            {
                return this["seller_email"];
            }

            protected set
            {
                this["seller_email"] = value;
            }
        }

        /// <summary>
        ///     商品的标题/交易标题/订单标题/订单关键字等。 
        /// </summary>
        public string Subject
        {
            get
            {
                return this["subject"];
            }

            protected set
            {
                this["subject"] = value;
            }
        }

        /// <summary>
        /// 该笔订单的资金总额
        /// </summary>
        public string TotalFee
        {
            get
            {
                return this["total_fee"];
            }

            protected set
            {
                this["total_fee"] = value;
            }
        }

        #endregion
    }
}